import httpUtils from "@/core/utils/http.utils";
// service path
const urls = {
    'getSysRolePage': `/api/upms/sysRole/page`,
    'getSysRoleById': `/api/upms/sysRole/`,
    'saveSysRole': `/api/upms/sysRole`, // 添加保存
    'updateSysRoleById': `/api/upms/sysRole`, // 修改
    'deleteSysRoleById': `/api/upms/sysRole/`, // 删除
    'getSysMenuTree': `/api/upms/sysMenu/tree`, // 获取菜单tree
    'getUsrSysMenuTree': `/api/upms/sysMenu/tree/`, // 获取用户角色菜单tree
    'updateRoleMenu': `/api/upms/sysRole/menu`, // 更新角色菜单
    'getSysOrgTree': `/api/upms/sysOrg/treeNoLog`,
};
// service methods
const sysRoleApi = {
    getSysMenuTree (params) {
        return httpUtils.get(urls.getSysMenuTree, params);
    },
    getUsrMenuTree (id) {
        return httpUtils.get(urls.getUsrSysMenuTree + id);
    },
    getSysRolePage (param) {
        return httpUtils.getEncrypt(urls.getSysRolePage, param);
    },
    getSysRoleById(id) {
        return httpUtils.get(urls.getSysRoleById + id, {});
    },
    saveSysRole(param) {
        return httpUtils.postEncrypt(urls.saveSysRole, param);
    },
    updateSysRoleById(params) {
        return httpUtils.putEncrypt(urls.updateSysRoleById, params);
    },
    updateRoleMenu(params) {
        return httpUtils.put(urls.updateRoleMenu, params);
    },
    deleteSysRole(ids) {
        let url = "";
        ids.forEach((item, index) => {
            if ("" !== url) {
                url = url + "&";
            }
            url = url + "id=" + item;
        })
        return httpUtils.delete(urls.deleteSysRoleById + ids);
    },
    getSysOrgTree () {
        return httpUtils.getEncrypt(urls.getSysOrgTree);
    },

};

export default sysRoleApi;
